<template>
    <div ref="chart" style="height:100%"></div>
</template>

<script>
import echarts from "echarts";
export default {
  name: "",
  components: {},
  props: {},
  data() {
    return {};
  },
  created() {},
  mounted() {
    this.initChart();
  },
  activited() {},
  update() {},
  beforeRouteUpdate() {},
  methods: {
    initChart() {
      var Charts = echarts.init(this.$refs.chart);
      var option = {
        xAxis: {
          type: "category",
          tooltip: {},
          axisLine: { show: false },
          axisLabel: {
            rotate: 50,
            color: "#2c6a5f",
            margin: 20,
            fontSize:16
          },
          data: [
            "2019-12-12 12:00",
            "2019-12-12 13:00",
            "2019-12-12 12:00",
            "2019-12-12 12:00",
            "2019-12-12 12:00",
            "2019-12-12 12:00",
            "2019-12-12 12:00"
          ].map(function(str) {
            return str.replace(" ", "\n\n");
          })
        },
        tooltip: {
          trigger: "axis",
          show: true,
          axisPointer: {
            lineStyle: {
              color: "#207064"
            }
          }
        },
        legend: {
          data: ["数据有效率", "仪器故障率", "仪器投用率"],
          // 默认选中第一个
          selected: { 数据有效率: true, 仪器故障率: false, 仪器投用率: false },
          show: true,
          left: "10%",
          top:20,
          //图例项的 icon
          icon: "circle",
          textStyle: {
            color: "#bebebe"
          }
        },
        grid: {
          left: 90,
          rigth:0,
          bottom:"15%"
        },
        yAxis: {
          axisLine: { show: false },
          dataMax: 42,
          //设置y轴的坐标轴刻度设置为虚线和颜色
          splitLine: {
            show: true,
            lineStyle: {
              color: "#2c6a5f",
              type: "dashed"
            }
          },
          type: "value",
          axisLabel: {
            color: "#2c6a5f"
          }
        },
        series: [
          {
            name: "数据有效率",
            type: "line",
            symbol: "rect",
            symbolSize: 10,
            data: [
              20,
              30,
              34,
              25,
              {
                value: 15,
                symbol: "rect",
                itemStyle: {
                  color: "red"
                }
              },
              29,
              38
            ],
            smooth: true,
            itemStyle: {
              color: "#207064"
            }
          },
          {
            name: "仪器故障率",
            type: "line",
            symbol: "rect",
            symbolSize: 10,
            data: [10, 20, 34, 35, 39, 30, 20],
            smooth: true,
            itemStyle: {
              color: "#207064"
            }
          },
          {
            name: "仪器投用率",
            type: "line",
            symbol: "rect",
            symbolSize: 10,
            data: [20, 30, 34, 25, 39, 20, 20],
            smooth: true,
            itemStyle: {
              color: "#207064"
            }
          }
        ]
      };
      Charts.setOption(option);
    }
  },
  filter: {},
  computed: {},
  watch: {}
};
</script>

<style lang="less" scoped>
</style>
